module dgl.Rectangle;

import str = tango.text.convert.Integer;

struct Rectangle
{
	private static Rectangle m_empty;
	
	public int x;
	
	public int y;
	
	public int width;
	
	public int height;
	
	public int left()
	{
		return x;
	}
	
	public int right()
	{
		return x + width;
	}
	
	public int top()
	{
		return y;
	}
	
	public int bottom()
	{
		return y + height;
	}
	
	static Rectangle opCall()
	{
		Rectangle ret;
		return ret;
	}
	
	static Rectangle opCall( int x, int y, int width, int height )
	{
		Rectangle ret;
		ret.x = x;
		ret.y = y;
		ret.width = width;
		ret.height = height;
		return ret;
	}
	
	public static Rectangle empty()
	{
		return Rectangle();
	}
	
	public char[] toString()
	{
		char[] ret = "";
		ret ~= "{";
		ret ~= " X:" ~ str.toString( x );
		ret ~= " Y:" ~ str.toString( y );
		ret ~= " W:" ~ str.toString( width );
		ret ~= " H:" ~ str.toString( height );
		ret ~= " }";
		return ret;
	}
}